package com.lanou3g.demo.base.service;

import com.lanou3g.demo.entity.*;
import com.lanou3g.demo.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AdminInfoService implements IAdminInfoService {

    @Autowired
    private AdminMapper adminMapper;


    @Override
    public List<AdminInfoQx> queryAdminAndRole() {
        List<AdminInfoQx> infoList = adminMapper.queryAdminAndRole();
        return infoList;
    }

    @Override
    public void insertAdminUserMessages(AdminInfo adminInfo) {
        adminMapper.insertAdminUserMessages(adminInfo);

    }

    @Override
    public void insertAdminRoles( List<AdminRole>adminRoles) {
        adminMapper.insertAdminRoles(adminRoles);
    }

    @Override
    public AdminInfo queryAdminIdByAdminCode(AdminInfo adminInfo) {
        return adminMapper.queryAdminIdByAdminCode(adminInfo);
    }

    @Override
    public List<RoleInfo> queryRoleInfo() {
        return adminMapper.queryRoleInfo();
    }

    @Override
    public AdminInfo queryAdminInfo(AdminInfo adminInfo) {
        return adminMapper.queryAdminInfo(adminInfo);
    }

    @Override
    public void updateAdminData(AdminInfo adminInfo,List<AdminRole>adminRoles) {
        adminMapper.updateAdminInfo(adminInfo);
        adminMapper.deleteAdminRole(adminInfo);
        adminMapper.insertAdminRoles(adminRoles);
    }

//    事务
    @Transactional
    @Override
    public void deleteAdmin(AdminInfo adminInfo) {
        adminMapper.deleteAdminInfo(adminInfo);
        adminMapper.deleteAdminRole(adminInfo);
    }

    @Override
    public List<AdminCondition> findAllByCondition(AdminCondition adminCondition) {
        return adminMapper.findAllByCondition(adminCondition);
    }

    @Override
    public List<ModuleInfo> queryModuleName() {
        return adminMapper.queryModuleName();
    }

//    @Override
//    public  List<RoleModule> queryRoleId(Integer moduleId) {
//        return adminMapper.queryRoleId(moduleId);
//    }

        @Override
    public  List<RoleModule> queryRoleId(RoleModule roleModule) {
        return adminMapper.queryRoleId(roleModule);
    }
    @Override
    public List<com.lanou3g.demo.entity.Service> findByPage(Integer page) {
        return adminMapper.findByPage(page);
    }

    @Override
    public void updatePassword(List<Integer> idList) {
        adminMapper.updatePassword(idList);
    }

    @Override
    public List<AdminInfoQx> queryRoleName(RoleInfo roleInfo) {
        return adminMapper.queryRoleName(roleInfo);
    }

    @Override
    public List<RoleInfo> queryRoleNameById(List<RoleModule> roleModuleList) {
        return adminMapper.queryRoleNameById(roleModuleList);
    }

    @Override
    public List<AdminInfoQx> queryRoleNames(List<RoleInfo> roleInfoList) {
        return adminMapper.queryRoleNames(roleInfoList);
    }


}
